#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define faster() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const int N=1e6;
//int dp[N];
using namespace std;
int main()
{
ll a,b,k,i,j,cn=0,ans=0;
cin>>a>>b>>k;
vector<ll>v;
v.pb(0);
for(i=a;i<=b;i++)
{
bool c=0;
if(i==1)
{
v.pb(0);
continue;
}
for(j=2;j<=sqrt(i);j++)
{
if(i%j==0)
{
c=1;
break;
}
}
if(!c)
cn++;
v.pb(cn);
}
ll n=v.size();
/*for(i=0;i<v.size();i++)
{
cout<<v[i]<<" ";
}*/
if(cn<k)
{
cout<<-1<<endl;
return 0;
}
for(i=0;i<n-1;i++)
{
ll x=v[i]+k;
auto it=lower_bound(v.begin(),v.end(),x)-v.begin();
ans=max(ans,(it-i));
}
cout<<ans<<endl;
return 0;
}
1353D - Constructing the Array | 1269C - Long Beautiful Integer |
1076A - Minimizing the String | 913C - Party Lemonade |
1313A - Fast Food Restaurant | 681A - A Good Contest |
1585F - Non-equal Neighbours | 747A - Display Size |
285A - Slightly Decreasing Permutations | 515C - Drazil and Factorial |
1151E - Number of Components | 1151F - Sonya and Informatics |
556A - Case of the Zeros and Ones | 867A - Between the Offices |
1569A - Balanced Substring | 260A - Adding Digits |
1698C - 3SUM Closure | 1029B - Creating the Contest |
1421A - XORwice | 1029A - Many Equal Substrings |
1675D - Vertical Paths | 1271C - Shawarma Tent |
805A - Fake NP | 1163A - Eating Soup |
787A - The Monster | 807A - Is it rated |
1096A - Find Divisible | 1430C - Numbers on Whiteboard |
1697B - Promo | 208D - Prizes Prizes more Prizes |